<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>微信支付</title>
    <link rel="stylesheet" href="<?php echo IMG_PATH ?>bdkd/css/reset.css" />
    <script src="<?php echo IMG_PATH ?>bdkd/js/flexible.js"></script>
    <link rel="stylesheet" href="<?php echo IMG_PATH ?>bdkd/css/zhifu.css">
    <link rel="stylesheet" href="<?php echo IMG_PATH ?>bdkd/css/swiper-3.4.2.min.css">
    <script src="<?php echo IMG_PATH ?>bdkd/js/jquery-1.11.1.min.js"></script>
    <script src="<?php echo IMG_PATH ?>bdkd/js/swiper-3.4.2.min.js"></script>
    <script src="<?php echo IMG_PATH ?>bdkd/js/ji_zhifu.js"></script>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
    <style>
        .kuang .box .fucen {
            width: 100%;
            height: 100%;
            position: absolute;
            top: 0;
            left: 0;
            z-index: 999;
            background: rgba(0, 0, 0, 0.4);
            display: none; }
        .kuang .box .fucen .beijing {
            width: 7.5066666667rem;
            height: 7.8666666667rem;
            background: #fff;
            border-radius: 10px;
            position: absolute;
            top: 38%;
            left: 50%;
            transform: translate(-50%, -50%);
            z-index: 999999999; }
        .kuang .box .fucen .beijing .fucen-top {
            /*width:100%;*/
            position: relative;
            height: 3.6rem;
            background-image: url("<?php echo IMG_PATH ?>bdkd/img/tan.png");
            background-repeat: no-repeat;
            background-size: 100%;
            background-position: center;
            border-top-left-radius: 0.1333333333rem;
            border-top-right-radius: 0.1333333333rem; }
        .kuang .box .fucen .beijing .fucen-top img {
            position: absolute;
            top: 0.48rem;
            right: 0.4533333333rem; }
        .kuang .box .fucen .beijing p {
            font-size: 13px;
            color: #333;
            text-align: center; }
        [data-dpr="2"] .kuang .box .fucen .beijing p {
            font-size: 26px; }
        [data-dpr="3"] .kuang .box .fucen .beijing p {
            font-size: 39px; }
        .kuang .box .fucen .beijing p:nth-child(2) {
            margin: 0.6666666667rem 0 0.24rem !important; }
        .kuang .box .fucen .beijing .btn1 {
            margin: 0.8rem auto;
            width: 4.5866666667rem;
            height: 1.0666666667rem;
            font-size: 14px;
            text-align: center;
            line-height: 1.0666666667rem;
            color: #fff;
            background: #14a5fb;
            border-radius: 0.5866666667rem;
            box-shadow: 0px 13px 30px 0px rgba(20, 164, 251, 0.44); }
        [data-dpr="2"] .kuang .box .fucen .beijing .btn1 {
            font-size: 28px; }
        [data-dpr="3"] .kuang .box .fucen .beijing .btn1 {
            font-size: 42px; }
    </style>
</head>
<body>
<?php
if($list && $worker){
    ?>
    <div class="kuang">
        <div class="box">
            <header>
                <i>*</i>感谢您使用便递 ,您的订单,共<i>1</i>单,请核实后付款。
            </header>
            <div class="fucen">
                <div class="beijing">
                    <div class="fucen-top">
                        <img onclick="add1()" src="<?php echo IMG_PATH ?>bdkd/img/x.png" height="30" width="28" alt="">
                    </div>
                    <p>邮递员输入的信息不符,</p>
                    <p>需邮递员重新填写,请耐心等待。</p>
                    <div class="btn1" onclick="upState()">确认</div>
                </div>
            </div>
            <section>
                <div class="swiper-container1">
                    <div class="swiper-wrapper">
                        <div class="swiper-slide">
                            <input type="hidden" id="qid" value="<?php echo $list->id;?>">
                            <div class="section-top">
                                <div class="wupin">代取物品说明</div>
                                <div class="pic"><img src="<?php echo IMG_PATH ?>bdkd/img/userActive.png" alt=""></div>
                            </div>
                            <div class="section-ul">
                                <ul>
                                    <li><span>代取员</span><span><?php echo $worker->realname;?></span></li>
                                    <li><span>快递单号</span><span><?php echo $list->ex_order;?></span></li>
                                    <li><span>物品标准</span><span><i>
                                                <?php
                                                if($list->standard==1){
                                                    ?>
                                                    0---5公斤（3元）
                                                    <?php
                                                }else{
                                                    ?>
                                                    5---10公斤（5元）
                                                    <?php
                                                }
                                                ?></i>KG</span></li>
                                    <li><span>下单时间</span><span><?php echo date("Y-m-d H:i:s",$list->time_add);?></span></li>
                                    <li><span>订单编号</span><span><?php echo $list->order_id;?></span></li>
                                    <li><a href="<?php echo SITE_PATH ?>work/buser/quan?type=1&id=<?php echo $list->id;?>&wtype=1"><span>优惠折扣</span><span><i>使用优惠券</i></span></a></li>
                                    <li><span>应付金额</span><span>￥<i><?php
                                                $money=$list->price;
                                                if(isset($zhekou) && !empty($zhekou)){
                                                    $money=$list->price-$zhekou;
                                                }

                                                echo $money;


                                                ?></i></span></li>
                                </ul>
                            </div>
                            <div class="section-bottom" id="rjx" onclick="appear()">
                                订单不符，请重新填写>>
                            </div>

                        </div>
                    </div>
                    <!-- 如果需要分页器 -->
                    <div class="swiper-pagination">

                    </div>
                </div>
                <div class="diandi"></div>

            </section>
            <footer>
                <div class="footer">
                    <h1>共<i>1</i>单，计<i><?php
                            $money=$list->price;
                            if(isset($zhekou) && !empty($zhekou)){
                                $money=$list->price-$zhekou;
                            }

                            echo $money;


                            ?></i>元</h1>
                    <p><i>* 注 :</i>请要求代取员师傅如实并且完整填写信息，本平台仅负责记录信息，否则不予负责。</p>
                </div>
            </footer>
            <div class="bottom">
                <div class="zhifu" onclick="pay()">
                    确认支付
                </div>
            </div>
        </div>
    </div>
    <?php
}else{
    ?>
    信息出错,请联系平台！
    <?php
}
?>
<!--<p><a style=" display:inline-block;width: 4rem; height: 2rem; border: 1px solid #006600;" href="javascript:window.location.reload()">刷新</a></p>
-->
<script type="text/javascript">
    function appear(){
        $('.fucen').css('display','block');

    }
    function upState() {
        var id=$("#qid").val();
        //获取值
        $.ajax({
            // 请求发送方式
            type: 'post',
            // 验证文件
            url: '<?php echo SITE_PATH ?>work/bpost/upState',
            dataType:'json',
            // 用户输入的帐号验证码
            data: {
                'id':id,
                'state': 1
            },

            success: function(data){
                console.log(data);
                if(data.result==1){
                    alert('修改成功!');
                }else {
                    alert('修改失败!');
                }
            },
            error: function(){
                alert('修改失败!');
            }

        })
    }

    function pay() {

        //获取金额
        var money = $('h1 i').last().text();
         //alert(money); return false;
        var id=$("#qid").val();
       // alert(id);
        //return false;
        $.ajax({
            // 请求发送方式
            type: 'post',
            // 验证文件
            url: '<?php echo SITE_PATH ?>work/bpost/doPay',
            dataType:'json',
            // 用户输入的帐号验证码
            data: {
                'attach':0,
                'money': money,
                'ids':id
            },

            success: function(data){
                console.log(data);
                if(data.result==0){
                    if(data.msg==3){
                        alert('支付失败!');
                    }else if(data.msg==4){
                        alert('缺少金额!');
                    }else if(data.msg==5){
                        alert('缺少订单!');
                    }else if(data.msg==7){
                        alert('您已付款!');
                    }else{
                        a(data.msg);
                    }
                }else {
                    alert('支付失败');
                }
            },
            error: function(){
                alert('支付失败!');
            }

        })

    }
    var mySwiper = new Swiper ('.swiper-container1', {

        autoplayDisableOnInteraction: false,//手势滑动以后，还可以自动滑动
        loop: true,
        // 如果需要分页器
        pagination: '.swiper-pagination',

    })


    //调用微信JS api 支付
    function jsApiCall(jsApiParameters)
    {
        // console.log('123132123');
        jsApiParameters = eval('(' + jsApiParameters + ')');
        //alert(jsApiParameters.appId);
        WeixinJSBridge.invoke(
            'getBrandWCPayRequest',{
                "appId":jsApiParameters.appId,     //公众号名称，由商户传入
                "timeStamp":jsApiParameters.timeStamp, //时间戳，自1970年以来的秒数
                "nonceStr":jsApiParameters.nonceStr, //随机串
                "package":jsApiParameters.package,
                "signType":jsApiParameters.signType, //微信签名方式：
                "paySign":jsApiParameters.paySign //微信签名
            },

            //    jsApiParameters,
            function(res){
                //alert(res.err_msg);  // 使用以上方式判断前端返回,微信团队郑重提示：res.err_msg将在用户支付成功后返
                if(res.err_msg=='get_brand_wcpay_request:cancel'){
                    alert('取消支付');
                }
            }
        );
    }
    function a(jsApiParameters)
    {
        // console.log(jsApiParameters);
        // console.log('456456');
        if (typeof WeixinJSBridge == "undefined"){
            if( document.addEventListener ){
                document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
            }else if (document.attachEvent){
                document.attachEvent('WeixinJSBridgeReady', jsApiCall);
                document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
            }
        }else{

            jsApiCall(jsApiParameters);
        }
    }


</script>
</body>
</html>